package com.ruiyangwang.ListenBook.util;

import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
import lombok.SneakyThrows;

import javax.sql.DataSource;
import java.sql.Connection;

/**
 * @author syzygy
 * @date 2022/07/09 14:43
 **/
public class DButil {
    private static final DataSource dataSourse;
    static {
        MysqlDataSource mysqlDataSource = new MysqlDataSource();
        mysqlDataSource.setURL("jdbc:mysql:///MyListenBook?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai");
        mysqlDataSource.setUser("root");
        mysqlDataSource.setPassword("123456");
        dataSourse = mysqlDataSource;
    }
    @SneakyThrows
    public static Connection connection(){
        return dataSourse.getConnection();
    }
}